﻿<UserControl x:Class="GSF.PhasorProtocols.UI.UserControls.AverageFrequencyUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ViewModels="clr-namespace:GSF.PhasorProtocols.UI.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="350" d:DesignWidth="600"
             Loaded="AverageFrequencyUserControl_Loaded" Unloaded="AverageFrequencyUserControl_Unloaded">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            <ViewModels:AverageFrequencyViewModel x:Key="ViewModel" />
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <Label Grid.Row="0" Grid.Column="0">Average Calculator</Label>
            <ComboBox Grid.Row="0" Grid.Column="1" Width="{StaticResource ItemSize}" ItemsSource="{Binding Path=CalculatorNames}" SelectedItem="{Binding Mode=TwoWay, Path=SelectedCalculatorName}" IsReadOnly="True"/>
        
            <Label Grid.Row="2" Grid.Column="0">Virtual Device</Label>
            <ComboBox Grid.Row="2" Grid.Column="1" Width="{StaticResource ItemSize}" ItemsSource="{Binding Path=VirtualDeviceNames}" SelectedItem="{Binding Mode=TwoWay, Path=SelectedVirtualDeviceName}" IsReadOnly="True" />
        </Grid>

        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <DataGrid Grid.Column="0" Height="500" ItemsSource="{Binding IOMappings}" SelectedItem="{Binding Mode=TwoWay, Path=SelectedIOMapping}" SelectionMode="Single" IsReadOnly="True">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Signal Reference" Binding="{Binding Mode=OneWay, Path=SignalReference}" />
                    <DataGridTextColumn Header="Input" Binding="{Binding Mode=OneWay, Path=InputKey}" />
                    <DataGridTextColumn Header="Output" Binding="{Binding Mode=OneWay, Path=OutputKey}" />
                </DataGrid.Columns>
            </DataGrid>
            
            <StackPanel Grid.Column="1" VerticalAlignment="Center">
                <Button Width="45" Height="23" Margin="5" Content="&lt;&lt;" Command="{Binding AddSelectedCommand}" />
                <Button Width="45" Height="23" Margin="5" Content="&gt;&gt;" Command="{Binding RemoveSelectedCommand}" />
            </StackPanel>

            <DataGrid Grid.Column="2" Height="500" ItemsSource="{Binding FrequencyMeasurements}" SelectedItem="{Binding Mode=TwoWay, Path=SelectedFrequencyMeasurement}" SelectionMode="Single" IsReadOnly="True">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Signal Reference" Binding="{Binding Mode=OneWay, Path=SignalReference}" />
                    <DataGridTextColumn Header="Measurement Key" Binding="{Binding Mode=OneWay, Path=Key}" />
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </Grid>
</UserControl>
